import React,{useState,useEffect} from "react"
import { Table, Tag, Space ,Button} from 'antd';
import {jobCfyList} from "../../api/job"

const columns = [
  {
    title: '分类ID',
    dataIndex: 'objectId',
    key: 'objectId',
  },
  {
    title: '分类名称',
    dataIndex: 'cfyname',
    key: 'cfyname',
  },
  {
    title: '归属分类',
    dataIndex: 'cfytype',
    key: 'cfytype',
  },
  {
    title: '分类图片',
    dataIndex: 'cfyimg',
    key: 'cfyimg',
    render:(url)=>{
      return <img src={url} style={{height:'50px'}} />
    }
  },
  {
    title: 'Action',
    key: 'action',
    render: (text, record) => (
      <Space size="middle">
        <Button type="primary" size="small">编辑 {record.name}</Button>
        <Button type="danger" size="small">删除</Button>
      </Space>
    ),
  },
];

const initdata = [
  {
    ObjectId: 'John Brown',
    cfyname: 32,
    cfytype: 'New York No. 1 Lake Park',
    cfyimg: ['nice', 'developer'],
  },
];

const CfyList=()=>{
  let [data,setData]=useState(initdata)
  useEffect(()=>{
    jobCfyList().then(res=>{
      console.log(res);
      setData(res.data.results)
    })
  },[])
  return <Table dataSource={data} columns={columns} />;
}

export default CfyList